/**
 * Copyright (C) 2021 - 2031 O-Cubes Co., Ltd.
 */

/****************************************************************
 *  @file    sm4.h
 *  @brief   SM4 algorithms header file
 *  @version v1.0
 *  @date    03. Apr. 2023
 ****************************************************************/

#ifndef __SM4_H__
#define __SM4_H__

#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SM4_KEY_SIZE     16
#define SM4_BLOCK_SIZE   16
#define SM4_RKEY_WORDS   32

struct crypto_sm4_ctx {
	u32 rkey_enc[SM4_RKEY_WORDS];
	u32 rkey_dec[SM4_RKEY_WORDS];
};

int sm4_expandkey(struct crypto_sm4_ctx *ctx, const u8 *in_key,
		  unsigned int key_len);

void sm4_encrypt(struct crypto_sm4_ctx *ctx, u8 *out, const u8 *in);
void sm4_decrypt(struct crypto_sm4_ctx *ctx, u8 *out, const u8 *in);

#ifdef __cplusplus
}
#endif

#endif /* __SM4_H__ */

